/**
 * AThread - Simple Thread class.
 * 
 * This class introduces basic concepts in setting up an application
 * with multiple threads. It is used in the prelab for Lab #2
 * 
 * @author  Anthony Varghese
 * @version 1.0
 * @date    August 30 2011
 */

package lab2;

public class AThread extends Thread {

	private static int asset = 0;
	public static final int target = 200;

	private int data = 0;

	/**
	 * Default Constructor
	 */
	public AThread() {
		data = 0;
	}

	/**
	 * Constructor with String parameter
	 * @param name
	 */
	public AThread(String name) {
		super(name);
	}

	/**
	 * public void run method 
	 * 
	 * this is where the work gets done in the thread
	 */
	public void run(){
		while (asset < target){
			work();
			asset += 10;
			System.out.println(" " + getName() + ": Asset is now " + asset);
		}
		System.out.println(" " + getName() + ": Performed " + data + " iterations.");
	}

	private void work(){
		data++;
	}
}
